package ocg.common.re.influx.Influx;

import org.influxdb.InfluxDB;
import org.influxdb.dto.Point.Builder;

/**
 * Created by chenbo on 2018/2/11.
 * InfluxDB数据库操作
 */
public class InfluxService {

    private InfluxDB influxDB;

    public InfluxService(InfluxDB influxDB) {
        this.influxDB = influxDB;
    }

    /**
     * 创建数据库
     * @param dataBase
     */
    public void createDatabase( String dataBase){
        this.influxDB.createDatabase ( dataBase );
    }

    /**
     * 插入数据
     * @param dataBase
     * @param builder
     * @return
     */
    public boolean insert( String dataBase , Builder builder ){
        influxDB.write ( dataBase , "" , builder.build () );
        return true;
    }

}
